home *** CD-ROM | disk | FTP | other *** search
Wrap
Attribute VB_Name = "Module1" Option Explicit Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long Dim msBMPList() As String Public Const SPI_SETDESKWALLPAPER = 20 Public Const SPIF_SENDWININICHANGE = &H2 Public Const SPIF_UPDATEINIFILE = &H1 Sub Main() AddToArray "C:\WinNT\BMPs\" Randomize SetWallpaper msBMPList(Int((UBound(msBMPList) * Rnd) + 1)) End Sub Public Sub SetWallpaper(ByVal FileName As String) Dim x As Long x = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, FileName, SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE) End Sub Sub AddToArray(sStartPath) Dim iCount As Integer Dim sFileName As String iCount = 0 Erase msBMPList sFileName = Dir(sStartPath) Do While sFileName <> "" If UCase(Right(sFileName, 4)) = ".BMP" Then iCount = iCount + 1 ReDim Preserve msBMPList(1 To iCount) As String msBMPList(iCount) = sStartPath & sFileName End If sFileName = Dir Loop End Sub